<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>登录</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />

		<link rel="stylesheet" href="AmazeUI-2.4.2/assets/css/amazeui.css" />
		<link href="css/dlstyle.css" rel="stylesheet" type="text/css">
	</head>
	<!--/************************************************************
 *																*
 * 						      							*
 *                        							*
 *       		  努力创建完善、持续更新插件以及模板			*
 * 																*
**************************************************************-->

	<body>

		<div class="login-boxtitle">
			<a href="home.html"><img alt="logo" src="images/logobig.png" /></a>
		</div>

		<div class="login-banner">
			<div class="login-main">
				<div class="login-banner-bg"><span></span><img src="images/big.jpg" /></div>
				<div class="login-box">
					<h3 class="title">登录商城</h3>
					<div class="clear"></div>
					<div class="login-form">
						<form>
							<div class="user-name">
								<label for="user"></label>
								<input type="text" name="name" id="name" placeholder="用户名">
							</div>
							<div class="user-pass">
								<label for="password"></label>
								<input type="password" name="password" id="password" placeholder="请输入密码">
							</div>
						</form>
					</div>
					<div class="login-links">
						<a href="register.html" class="zcnext am-fr am-btn-default">注册</a>
						<br />
					</div>
					<div class="am-cf">
						<input type="submit" name="" id="but" value="登 录" class="am-btn am-btn-primary am-btn-sm">
					</div>
					<div class="partner">
						<a href="admin/managerlogin.html">管理员登录</a>
					</div>
				</div>
			</div>
		</div>
	</body>

	<script src="js/jquery-1.7.2.min.js"></script>
	<script>
		function login() {
			var name = $("#name");
			var password = $("#password");
			var but = $("#but");
			but.click(function() {

				$.ajax({
					//请求方式
					type: "POST",
					//请求的媒体类型					//请求地址
					url: "http://localhost:8080/credits_exchange/user/login",
					//数据，json字符串
					data: {
						"name":name.val(),
						"password":password.val()
		
					},
					//请求成功
					success: function(result) {
						console.log(result);
/*						alert(result.code)
*/						if(result.code==200){
							alert("登陆成功")
							localStorage.setItem("token",result.data.token);
							window.location.href="index.html"
						}else{
							alert(result.msg)
						}
					},
					//请求失败，包含具体的错误信息
					error: function(e) {
						console.log(e.status);
						console.log(e.responseText);
					}
				});

			});

		}
		login()
		
	</script>

</html>